﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>01m: Sprite Example</title>
	<style type="text/css">
		body, html {
			width: 100%;
			height: 100%;
			margin: 0;
			background-color: #FFFFF0;
			overflow: hidden;
		}
	</style>
	<script src="../../../bootloader.js" type="text/javascript"></script>
	<script type="text/javascript">
		go = function() {
			stage = new opus.Container({
				parentNode: document.body,
				styles: {position: "absolute", border: 8, padding: 32, borderColor: "green"},
				defaultControlType: "Sprite",
				spriteList: "$library/opus/controls/test/images/soldier_42_46",
				controls: [
					{l:0, t:0, spriteCol: 0, speed: 4},
					{l:0, t:128, spriteCol: 3, speed: 6},
					{l:0, t:256, spriteCol: 6, speed: 3},
					{l:0, t:384, spriteCol: 9, speed: 7}
				]
			});
			// Fit our container to the screen
			resize();
			// Render everything
			stage.render();
			// Animate progress bar for fun
			fn = function() {
				for (var i=0, c, l; (c=stage.c$[i]); i++) {
					l = c.left + c.speed;
					if (l >= stage.bounds.w + 60) {
						l = -60;
					}
					c.setLeft(l);
					c.setSpriteCol((c.spriteCol + 1) % 12);
				}
			};
			var job = setInterval(fn, 50);
		}
		resize = function() {
			stage.setBounds({w: document.body.offsetWidth, h: document.body.offsetHeight});
		}
	</script>
</head>
<body onload="go()" onresize="resize()">
</body>
</html>
